- /* sdfsinSR.cpp by K.Tsuru */
- // function ID 3105 DRADIX
- /***************
- SDouble class
- sin x
- using sereies and reduction method.
- Old version's Sin(x) before ver 2.2.
- ****************/
- #ifndef SN_H
- #include "sn.h"
- #endif
-
- #define usesSinSeriesInSin 1 // for a test.
-
- SDouble SinS_RN(const SDouble& x){
- if(x.Sign() == 0) return x; // x = 0
- #if usesSinSeriesInSin
- // |x| is very small.
- if(x.NetRdxExp() < -4) return SinSeries(x); // |x| < 1.0e-16 ver.2.18
-
- uint fig = x.Last() - x.First() +1u;
- double c;
-
- if(fig <= 5u){ // x has the figures les than five.
- double dblX = doubleD(x, 0), absX = fabs(dblX);
- // x is short and small, then call SinSeries()
- c = (absX > M_PI_4) ? 1.0 : log10((double)x.MaxSize()*absX) - 1.6;
- if(c < 0) return SinSeries(x);
- }
- #endif
- SDouble y, r;
- int func = SIN_CALC;
- int sgn = GetTriCalcMethod(x, y, &func);// |y| < pi/4
- if(sgn == 0){ // y = -1, 0, 1
- x.upToTerm = 0;
- return y;
- }
- #if usesSinSeriesInSin
- // x is long but small.
- double dblY = doubleD(y), absY = fabs(dblY);
- c = (double)x.MaxSize()/64 + log10(absY) + 0.2;
- if(c < 0){
- if(func == COS_CALC) r = CosSeries(y);
- else r = SinSeries(y);
- goto Ret;
- }
- #endif
- //RN : using x/R^n reduction method
- if(func == COS_CALC) r = CosRN(y);
- else r = SinRN(y);
- Ret:
- if(sgn < 0) r.ChangeSign(); // r = -r;
- return r;
- }
sdfsinSR.cpp : last modifiled at 2017/05/08 15:03:00(1,382 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).